package br.com.virtual.relatorio.service.impl;

import java.util.Calendar;
import java.util.List;

import javax.inject.Inject;

import br.com.virtual.relatorio.dao.impl.RelatorioVendasDAOImpl;
import br.com.virtual.relatorio.model.Periodo;
import br.com.virtual.relatorio.model.Relatorio;
import br.com.virtual.relatorio.service.RelatorioService;
import br.com.virtual.relatorio.service.RelatorioVendasService;
import br.com.virtual.vender.model.Venda;


public class RelatorioVendasServiceImpl implements RelatorioVendasService, RelatorioService<Venda> {

	@Inject
	RelatorioVendasDAOImpl relatorioVendasDAO;
	
	@Override
	public Relatorio<Venda> generate(Calendar start, Calendar end) {

		Relatorio<Venda> relatorio = new Relatorio<Venda>(new Periodo(start, end));		
		List<Venda> vendas = relatorioVendasDAO.listByPeriod(start, end);
		
		for(Venda venda : vendas){
			relatorio.addItem(venda, venda.getDataVenda(), venda.getTotalVenda());
		}
		
		return relatorio;
	}

}
